/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
/**
 * Autogenerated by Thrift Compiler (0.11.0)
 *
 * <p>DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *
 * @generated
 */
package org.apache.pegasus.apps;

import org.apache.pegasus.base.blob;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(
    value = "Autogenerated by Thrift Compiler (0.11.0)",
    date = "2020-04-13")
public class check_and_set_request
    implements org.apache.thrift.TBase<check_and_set_request, check_and_set_request._Fields>,
        java.io.Serializable,
        Cloneable,
        Comparable<check_and_set_request> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
      new org.apache.thrift.protocol.TStruct("check_and_set_request");

  private static final org.apache.thrift.protocol.TField HASH_KEY_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "hash_key", org.apache.thrift.protocol.TType.STRUCT, (short) 1);
  private static final org.apache.thrift.protocol.TField CHECK_SORT_KEY_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "check_sort_key", org.apache.thrift.protocol.TType.STRUCT, (short) 2);
  private static final org.apache.thrift.protocol.TField CHECK_TYPE_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "check_type", org.apache.thrift.protocol.TType.I32, (short) 3);
  private static final org.apache.thrift.protocol.TField CHECK_OPERAND_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "check_operand", org.apache.thrift.protocol.TType.STRUCT, (short) 4);
  private static final org.apache.thrift.protocol.TField SET_DIFF_SORT_KEY_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "set_diff_sort_key", org.apache.thrift.protocol.TType.BOOL, (short) 5);
  private static final org.apache.thrift.protocol.TField SET_SORT_KEY_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "set_sort_key", org.apache.thrift.protocol.TType.STRUCT, (short) 6);
  private static final org.apache.thrift.protocol.TField SET_VALUE_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "set_value", org.apache.thrift.protocol.TType.STRUCT, (short) 7);
  private static final org.apache.thrift.protocol.TField SET_EXPIRE_TS_SECONDS_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "set_expire_ts_seconds", org.apache.thrift.protocol.TType.I32, (short) 8);
  private static final org.apache.thrift.protocol.TField RETURN_CHECK_VALUE_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "return_check_value", org.apache.thrift.protocol.TType.BOOL, (short) 9);

  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY =
      new check_and_set_requestStandardSchemeFactory();
  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY =
      new check_and_set_requestTupleSchemeFactory();

  public blob hash_key; // required
  public blob check_sort_key; // required
  /** @see cas_check_type */
  public cas_check_type check_type; // required

  public blob check_operand; // required
  public boolean set_diff_sort_key; // required
  public blob set_sort_key; // required
  public blob set_value; // required
  public int set_expire_ts_seconds; // required
  public boolean return_check_value; // required

  /**
   * The set of fields this struct contains, along with convenience methods for finding and
   * manipulating them.
   */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    HASH_KEY((short) 1, "hash_key"),
    CHECK_SORT_KEY((short) 2, "check_sort_key"),
    /** @see cas_check_type */
    CHECK_TYPE((short) 3, "check_type"),
    CHECK_OPERAND((short) 4, "check_operand"),
    SET_DIFF_SORT_KEY((short) 5, "set_diff_sort_key"),
    SET_SORT_KEY((short) 6, "set_sort_key"),
    SET_VALUE((short) 7, "set_value"),
    SET_EXPIRE_TS_SECONDS((short) 8, "set_expire_ts_seconds"),
    RETURN_CHECK_VALUE((short) 9, "return_check_value");

    private static final java.util.Map<java.lang.String, _Fields> byName =
        new java.util.HashMap<java.lang.String, _Fields>();

    static {
      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }

    /** Find the _Fields constant that matches fieldId, or null if its not found. */
    public static _Fields findByThriftId(int fieldId) {
      switch (fieldId) {
        case 1: // HASH_KEY
          return HASH_KEY;
        case 2: // CHECK_SORT_KEY
          return CHECK_SORT_KEY;
        case 3: // CHECK_TYPE
          return CHECK_TYPE;
        case 4: // CHECK_OPERAND
          return CHECK_OPERAND;
        case 5: // SET_DIFF_SORT_KEY
          return SET_DIFF_SORT_KEY;
        case 6: // SET_SORT_KEY
          return SET_SORT_KEY;
        case 7: // SET_VALUE
          return SET_VALUE;
        case 8: // SET_EXPIRE_TS_SECONDS
          return SET_EXPIRE_TS_SECONDS;
        case 9: // RETURN_CHECK_VALUE
          return RETURN_CHECK_VALUE;
        default:
          return null;
      }
    }

    /** Find the _Fields constant that matches fieldId, throwing an exception if it is not found. */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null)
        throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /** Find the _Fields constant that matches name, or null if its not found. */
    public static _Fields findByName(java.lang.String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final java.lang.String _fieldName;

    _Fields(short thriftId, java.lang.String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public java.lang.String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __SET_DIFF_SORT_KEY_ISSET_ID = 0;
  private static final int __SET_EXPIRE_TS_SECONDS_ISSET_ID = 1;
  private static final int __RETURN_CHECK_VALUE_ISSET_ID = 2;
  private byte __isset_bitfield = 0;
  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;

  static {
    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap =
        new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(
        _Fields.HASH_KEY,
        new org.apache.thrift.meta_data.FieldMetaData(
            "hash_key",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.StructMetaData(
                org.apache.thrift.protocol.TType.STRUCT, blob.class)));
    tmpMap.put(
        _Fields.CHECK_SORT_KEY,
        new org.apache.thrift.meta_data.FieldMetaData(
            "check_sort_key",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.StructMetaData(
                org.apache.thrift.protocol.TType.STRUCT, blob.class)));
    tmpMap.put(
        _Fields.CHECK_TYPE,
        new org.apache.thrift.meta_data.FieldMetaData(
            "check_type",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.EnumMetaData(
                org.apache.thrift.protocol.TType.ENUM, cas_check_type.class)));
    tmpMap.put(
        _Fields.CHECK_OPERAND,
        new org.apache.thrift.meta_data.FieldMetaData(
            "check_operand",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.StructMetaData(
                org.apache.thrift.protocol.TType.STRUCT, blob.class)));
    tmpMap.put(
        _Fields.SET_DIFF_SORT_KEY,
        new org.apache.thrift.meta_data.FieldMetaData(
            "set_diff_sort_key",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.FieldValueMetaData(
                org.apache.thrift.protocol.TType.BOOL)));
    tmpMap.put(
        _Fields.SET_SORT_KEY,
        new org.apache.thrift.meta_data.FieldMetaData(
            "set_sort_key",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.StructMetaData(
                org.apache.thrift.protocol.TType.STRUCT, blob.class)));
    tmpMap.put(
        _Fields.SET_VALUE,
        new org.apache.thrift.meta_data.FieldMetaData(
            "set_value",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.StructMetaData(
                org.apache.thrift.protocol.TType.STRUCT, blob.class)));
    tmpMap.put(
        _Fields.SET_EXPIRE_TS_SECONDS,
        new org.apache.thrift.meta_data.FieldMetaData(
            "set_expire_ts_seconds",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.FieldValueMetaData(
                org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(
        _Fields.RETURN_CHECK_VALUE,
        new org.apache.thrift.meta_data.FieldMetaData(
            "return_check_value",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.FieldValueMetaData(
                org.apache.thrift.protocol.TType.BOOL)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(
        check_and_set_request.class, metaDataMap);
  }

  public check_and_set_request() {}

  public check_and_set_request(
      blob hash_key,
      blob check_sort_key,
      cas_check_type check_type,
      blob check_operand,
      boolean set_diff_sort_key,
      blob set_sort_key,
      blob set_value,
      int set_expire_ts_seconds,
      boolean return_check_value) {
    this();
    this.hash_key = hash_key;
    this.check_sort_key = check_sort_key;
    this.check_type = check_type;
    this.check_operand = check_operand;
    this.set_diff_sort_key = set_diff_sort_key;
    setSet_diff_sort_keyIsSet(true);
    this.set_sort_key = set_sort_key;
    this.set_value = set_value;
    this.set_expire_ts_seconds = set_expire_ts_seconds;
    setSet_expire_ts_secondsIsSet(true);
    this.return_check_value = return_check_value;
    setReturn_check_valueIsSet(true);
  }

  /** Performs a deep copy on <i>other</i>. */
  public check_and_set_request(check_and_set_request other) {
    __isset_bitfield = other.__isset_bitfield;
    if (other.isSetHash_key()) {
      this.hash_key = new blob(other.hash_key);
    }
    if (other.isSetCheck_sort_key()) {
      this.check_sort_key = new blob(other.check_sort_key);
    }
    if (other.isSetCheck_type()) {
      this.check_type = other.check_type;
    }
    if (other.isSetCheck_operand()) {
      this.check_operand = new blob(other.check_operand);
    }
    this.set_diff_sort_key = other.set_diff_sort_key;
    if (other.isSetSet_sort_key()) {
      this.set_sort_key = new blob(other.set_sort_key);
    }
    if (other.isSetSet_value()) {
      this.set_value = new blob(other.set_value);
    }
    this.set_expire_ts_seconds = other.set_expire_ts_seconds;
    this.return_check_value = other.return_check_value;
  }

  public check_and_set_request deepCopy() {
    return new check_and_set_request(this);
  }

  @Override
  public void clear() {
    this.hash_key = null;
    this.check_sort_key = null;
    this.check_type = null;
    this.check_operand = null;
    setSet_diff_sort_keyIsSet(false);
    this.set_diff_sort_key = false;
    this.set_sort_key = null;
    this.set_value = null;
    setSet_expire_ts_secondsIsSet(false);
    this.set_expire_ts_seconds = 0;
    setReturn_check_valueIsSet(false);
    this.return_check_value = false;
  }

  public blob getHash_key() {
    return this.hash_key;
  }

  public check_and_set_request setHash_key(blob hash_key) {
    this.hash_key = hash_key;
    return this;
  }

  public void unsetHash_key() {
    this.hash_key = null;
  }

  /** Returns true if field hash_key is set (has been assigned a value) and false otherwise */
  public boolean isSetHash_key() {
    return this.hash_key != null;
  }

  public void setHash_keyIsSet(boolean value) {
    if (!value) {
      this.hash_key = null;
    }
  }

  public blob getCheck_sort_key() {
    return this.check_sort_key;
  }

  public check_and_set_request setCheck_sort_key(blob check_sort_key) {
    this.check_sort_key = check_sort_key;
    return this;
  }

  public void unsetCheck_sort_key() {
    this.check_sort_key = null;
  }

  /** Returns true if field check_sort_key is set (has been assigned a value) and false otherwise */
  public boolean isSetCheck_sort_key() {
    return this.check_sort_key != null;
  }

  public void setCheck_sort_keyIsSet(boolean value) {
    if (!value) {
      this.check_sort_key = null;
    }
  }

  /** @see cas_check_type */
  public cas_check_type getCheck_type() {
    return this.check_type;
  }

  /** @see cas_check_type */
  public check_and_set_request setCheck_type(cas_check_type check_type) {
    this.check_type = check_type;
    return this;
  }

  public void unsetCheck_type() {
    this.check_type = null;
  }

  /** Returns true if field check_type is set (has been assigned a value) and false otherwise */
  public boolean isSetCheck_type() {
    return this.check_type != null;
  }

  public void setCheck_typeIsSet(boolean value) {
    if (!value) {
      this.check_type = null;
    }
  }

  public blob getCheck_operand() {
    return this.check_operand;
  }

  public check_and_set_request setCheck_operand(blob check_operand) {
    this.check_operand = check_operand;
    return this;
  }

  public void unsetCheck_operand() {
    this.check_operand = null;
  }

  /** Returns true if field check_operand is set (has been assigned a value) and false otherwise */
  public boolean isSetCheck_operand() {
    return this.check_operand != null;
  }

  public void setCheck_operandIsSet(boolean value) {
    if (!value) {
      this.check_operand = null;
    }
  }

  public boolean isSet_diff_sort_key() {
    return this.set_diff_sort_key;
  }

  public check_and_set_request setSet_diff_sort_key(boolean set_diff_sort_key) {
    this.set_diff_sort_key = set_diff_sort_key;
    setSet_diff_sort_keyIsSet(true);
    return this;
  }

  public void unsetSet_diff_sort_key() {
    __isset_bitfield =
        org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SET_DIFF_SORT_KEY_ISSET_ID);
  }

  /**
   * Returns true if field set_diff_sort_key is set (has been assigned a value) and false otherwise
   */
  public boolean isSetSet_diff_sort_key() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SET_DIFF_SORT_KEY_ISSET_ID);
  }

  public void setSet_diff_sort_keyIsSet(boolean value) {
    __isset_bitfield =
        org.apache.thrift.EncodingUtils.setBit(
            __isset_bitfield, __SET_DIFF_SORT_KEY_ISSET_ID, value);
  }

  public blob getSet_sort_key() {
    return this.set_sort_key;
  }

  public check_and_set_request setSet_sort_key(blob set_sort_key) {
    this.set_sort_key = set_sort_key;
    return this;
  }

  public void unsetSet_sort_key() {
    this.set_sort_key = null;
  }

  /** Returns true if field set_sort_key is set (has been assigned a value) and false otherwise */
  public boolean isSetSet_sort_key() {
    return this.set_sort_key != null;
  }

  public void setSet_sort_keyIsSet(boolean value) {
    if (!value) {
      this.set_sort_key = null;
    }
  }

  public blob getSet_value() {
    return this.set_value;
  }

  public check_and_set_request setSet_value(blob set_value) {
    this.set_value = set_value;
    return this;
  }

  public void unsetSet_value() {
    this.set_value = null;
  }

  /** Returns true if field set_value is set (has been assigned a value) and false otherwise */
  public boolean isSetSet_value() {
    return this.set_value != null;
  }

  public void setSet_valueIsSet(boolean value) {
    if (!value) {
      this.set_value = null;
    }
  }

  public int getSet_expire_ts_seconds() {
    return this.set_expire_ts_seconds;
  }

  public check_and_set_request setSet_expire_ts_seconds(int set_expire_ts_seconds) {
    this.set_expire_ts_seconds = set_expire_ts_seconds;
    setSet_expire_ts_secondsIsSet(true);
    return this;
  }

  public void unsetSet_expire_ts_seconds() {
    __isset_bitfield =
        org.apache.thrift.EncodingUtils.clearBit(
            __isset_bitfield, __SET_EXPIRE_TS_SECONDS_ISSET_ID);
  }

  /**
   * Returns true if field set_expire_ts_seconds is set (has been assigned a value) and false
   * otherwise
   */
  public boolean isSetSet_expire_ts_seconds() {
    return org.apache.thrift.EncodingUtils.testBit(
        __isset_bitfield, __SET_EXPIRE_TS_SECONDS_ISSET_ID);
  }

  public void setSet_expire_ts_secondsIsSet(boolean value) {
    __isset_bitfield =
        org.apache.thrift.EncodingUtils.setBit(
            __isset_bitfield, __SET_EXPIRE_TS_SECONDS_ISSET_ID, value);
  }

  public boolean isReturn_check_value() {
    return this.return_check_value;
  }

  public check_and_set_request setReturn_check_value(boolean return_check_value) {
    this.return_check_value = return_check_value;
    setReturn_check_valueIsSet(true);
    return this;
  }

  public void unsetReturn_check_value() {
    __isset_bitfield =
        org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __RETURN_CHECK_VALUE_ISSET_ID);
  }

  /**
   * Returns true if field return_check_value is set (has been assigned a value) and false otherwise
   */
  public boolean isSetReturn_check_value() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __RETURN_CHECK_VALUE_ISSET_ID);
  }

  public void setReturn_check_valueIsSet(boolean value) {
    __isset_bitfield =
        org.apache.thrift.EncodingUtils.setBit(
            __isset_bitfield, __RETURN_CHECK_VALUE_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, java.lang.Object value) {
    switch (field) {
      case HASH_KEY:
        if (value == null) {
          unsetHash_key();
        } else {
          setHash_key((blob) value);
        }
        break;

      case CHECK_SORT_KEY:
        if (value == null) {
          unsetCheck_sort_key();
        } else {
          setCheck_sort_key((blob) value);
        }
        break;

      case CHECK_TYPE:
        if (value == null) {
          unsetCheck_type();
        } else {
          setCheck_type((cas_check_type) value);
        }
        break;

      case CHECK_OPERAND:
        if (value == null) {
          unsetCheck_operand();
        } else {
          setCheck_operand((blob) value);
        }
        break;

      case SET_DIFF_SORT_KEY:
        if (value == null) {
          unsetSet_diff_sort_key();
        } else {
          setSet_diff_sort_key((java.lang.Boolean) value);
        }
        break;

      case SET_SORT_KEY:
        if (value == null) {
          unsetSet_sort_key();
        } else {
          setSet_sort_key((blob) value);
        }
        break;

      case SET_VALUE:
        if (value == null) {
          unsetSet_value();
        } else {
          setSet_value((blob) value);
        }
        break;

      case SET_EXPIRE_TS_SECONDS:
        if (value == null) {
          unsetSet_expire_ts_seconds();
        } else {
          setSet_expire_ts_seconds((java.lang.Integer) value);
        }
        break;

      case RETURN_CHECK_VALUE:
        if (value == null) {
          unsetReturn_check_value();
        } else {
          setReturn_check_value((java.lang.Boolean) value);
        }
        break;
    }
  }

  public java.lang.Object getFieldValue(_Fields field) {
    switch (field) {
      case HASH_KEY:
        return getHash_key();

      case CHECK_SORT_KEY:
        return getCheck_sort_key();

      case CHECK_TYPE:
        return getCheck_type();

      case CHECK_OPERAND:
        return getCheck_operand();

      case SET_DIFF_SORT_KEY:
        return isSet_diff_sort_key();

      case SET_SORT_KEY:
        return getSet_sort_key();

      case SET_VALUE:
        return getSet_value();

      case SET_EXPIRE_TS_SECONDS:
        return getSet_expire_ts_seconds();

      case RETURN_CHECK_VALUE:
        return isReturn_check_value();
    }
    throw new java.lang.IllegalStateException();
  }

  /**
   * Returns true if field corresponding to fieldID is set (has been assigned a value) and false
   * otherwise
   */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new java.lang.IllegalArgumentException();
    }

    switch (field) {
      case HASH_KEY:
        return isSetHash_key();
      case CHECK_SORT_KEY:
        return isSetCheck_sort_key();
      case CHECK_TYPE:
        return isSetCheck_type();
      case CHECK_OPERAND:
        return isSetCheck_operand();
      case SET_DIFF_SORT_KEY:
        return isSetSet_diff_sort_key();
      case SET_SORT_KEY:
        return isSetSet_sort_key();
      case SET_VALUE:
        return isSetSet_value();
      case SET_EXPIRE_TS_SECONDS:
        return isSetSet_expire_ts_seconds();
      case RETURN_CHECK_VALUE:
        return isSetReturn_check_value();
    }
    throw new java.lang.IllegalStateException();
  }

  @Override
  public boolean equals(java.lang.Object that) {
    if (that == null) return false;
    if (that instanceof check_and_set_request) return this.equals((check_and_set_request) that);
    return false;
  }

  public boolean equals(check_and_set_request that) {
    if (that == null) return false;
    if (this == that) return true;

    boolean this_present_hash_key = true && this.isSetHash_key();
    boolean that_present_hash_key = true && that.isSetHash_key();
    if (this_present_hash_key || that_present_hash_key) {
      if (!(this_present_hash_key && that_present_hash_key)) return false;
      if (!this.hash_key.equals(that.hash_key)) return false;
    }

    boolean this_present_check_sort_key = true && this.isSetCheck_sort_key();
    boolean that_present_check_sort_key = true && that.isSetCheck_sort_key();
    if (this_present_check_sort_key || that_present_check_sort_key) {
      if (!(this_present_check_sort_key && that_present_check_sort_key)) return false;
      if (!this.check_sort_key.equals(that.check_sort_key)) return false;
    }

    boolean this_present_check_type = true && this.isSetCheck_type();
    boolean that_present_check_type = true && that.isSetCheck_type();
    if (this_present_check_type || that_present_check_type) {
      if (!(this_present_check_type && that_present_check_type)) return false;
      if (!this.check_type.equals(that.check_type)) return false;
    }

    boolean this_present_check_operand = true && this.isSetCheck_operand();
    boolean that_present_check_operand = true && that.isSetCheck_operand();
    if (this_present_check_operand || that_present_check_operand) {
      if (!(this_present_check_operand && that_present_check_operand)) return false;
      if (!this.check_operand.equals(that.check_operand)) return false;
    }

    boolean this_present_set_diff_sort_key = true;
    boolean that_present_set_diff_sort_key = true;
    if (this_present_set_diff_sort_key || that_present_set_diff_sort_key) {
      if (!(this_present_set_diff_sort_key && that_present_set_diff_sort_key)) return false;
      if (this.set_diff_sort_key != that.set_diff_sort_key) return false;
    }

    boolean this_present_set_sort_key = true && this.isSetSet_sort_key();
    boolean that_present_set_sort_key = true && that.isSetSet_sort_key();
    if (this_present_set_sort_key || that_present_set_sort_key) {
      if (!(this_present_set_sort_key && that_present_set_sort_key)) return false;
      if (!this.set_sort_key.equals(that.set_sort_key)) return false;
    }

    boolean this_present_set_value = true && this.isSetSet_value();
    boolean that_present_set_value = true && that.isSetSet_value();
    if (this_present_set_value || that_present_set_value) {
      if (!(this_present_set_value && that_present_set_value)) return false;
      if (!this.set_value.equals(that.set_value)) return false;
    }

    boolean this_present_set_expire_ts_seconds = true;
    boolean that_present_set_expire_ts_seconds = true;
    if (this_present_set_expire_ts_seconds || that_present_set_expire_ts_seconds) {
      if (!(this_present_set_expire_ts_seconds && that_present_set_expire_ts_seconds)) return false;
      if (this.set_expire_ts_seconds != that.set_expire_ts_seconds) return false;
    }

    boolean this_present_return_check_value = true;
    boolean that_present_return_check_value = true;
    if (this_present_return_check_value || that_present_return_check_value) {
      if (!(this_present_return_check_value && that_present_return_check_value)) return false;
      if (this.return_check_value != that.return_check_value) return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int hashCode = 1;

    hashCode = hashCode * 8191 + ((isSetHash_key()) ? 131071 : 524287);
    if (isSetHash_key()) hashCode = hashCode * 8191 + hash_key.hashCode();

    hashCode = hashCode * 8191 + ((isSetCheck_sort_key()) ? 131071 : 524287);
    if (isSetCheck_sort_key()) hashCode = hashCode * 8191 + check_sort_key.hashCode();

    hashCode = hashCode * 8191 + ((isSetCheck_type()) ? 131071 : 524287);
    if (isSetCheck_type()) hashCode = hashCode * 8191 + check_type.getValue();

    hashCode = hashCode * 8191 + ((isSetCheck_operand()) ? 131071 : 524287);
    if (isSetCheck_operand()) hashCode = hashCode * 8191 + check_operand.hashCode();

    hashCode = hashCode * 8191 + ((set_diff_sort_key) ? 131071 : 524287);

    hashCode = hashCode * 8191 + ((isSetSet_sort_key()) ? 131071 : 524287);
    if (isSetSet_sort_key()) hashCode = hashCode * 8191 + set_sort_key.hashCode();

    hashCode = hashCode * 8191 + ((isSetSet_value()) ? 131071 : 524287);
    if (isSetSet_value()) hashCode = hashCode * 8191 + set_value.hashCode();

    hashCode = hashCode * 8191 + set_expire_ts_seconds;

    hashCode = hashCode * 8191 + ((return_check_value) ? 131071 : 524287);

    return hashCode;
  }

  @Override
  public int compareTo(check_and_set_request other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.valueOf(isSetHash_key()).compareTo(other.isSetHash_key());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetHash_key()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hash_key, other.hash_key);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison =
        java.lang.Boolean.valueOf(isSetCheck_sort_key()).compareTo(other.isSetCheck_sort_key());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCheck_sort_key()) {
      lastComparison =
          org.apache.thrift.TBaseHelper.compareTo(this.check_sort_key, other.check_sort_key);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison =
        java.lang.Boolean.valueOf(isSetCheck_type()).compareTo(other.isSetCheck_type());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCheck_type()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.check_type, other.check_type);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison =
        java.lang.Boolean.valueOf(isSetCheck_operand()).compareTo(other.isSetCheck_operand());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCheck_operand()) {
      lastComparison =
          org.apache.thrift.TBaseHelper.compareTo(this.check_operand, other.check_operand);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison =
        java.lang.Boolean.valueOf(isSetSet_diff_sort_key())
            .compareTo(other.isSetSet_diff_sort_key());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSet_diff_sort_key()) {
      lastComparison =
          org.apache.thrift.TBaseHelper.compareTo(this.set_diff_sort_key, other.set_diff_sort_key);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison =
        java.lang.Boolean.valueOf(isSetSet_sort_key()).compareTo(other.isSetSet_sort_key());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSet_sort_key()) {
      lastComparison =
          org.apache.thrift.TBaseHelper.compareTo(this.set_sort_key, other.set_sort_key);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetSet_value()).compareTo(other.isSetSet_value());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSet_value()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.set_value, other.set_value);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison =
        java.lang.Boolean.valueOf(isSetSet_expire_ts_seconds())
            .compareTo(other.isSetSet_expire_ts_seconds());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSet_expire_ts_seconds()) {
      lastComparison =
          org.apache.thrift.TBaseHelper.compareTo(
              this.set_expire_ts_seconds, other.set_expire_ts_seconds);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison =
        java.lang.Boolean.valueOf(isSetReturn_check_value())
            .compareTo(other.isSetReturn_check_value());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetReturn_check_value()) {
      lastComparison =
          org.apache.thrift.TBaseHelper.compareTo(
              this.return_check_value, other.return_check_value);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    scheme(iprot).read(iprot, this);
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot)
      throws org.apache.thrift.TException {
    scheme(oprot).write(oprot, this);
  }

  @Override
  public java.lang.String toString() {
    java.lang.StringBuilder sb = new java.lang.StringBuilder("check_and_set_request(");
    boolean first = true;

    sb.append("hash_key:");
    if (this.hash_key == null) {
      sb.append("null");
    } else {
      sb.append(this.hash_key);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("check_sort_key:");
    if (this.check_sort_key == null) {
      sb.append("null");
    } else {
      sb.append(this.check_sort_key);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("check_type:");
    if (this.check_type == null) {
      sb.append("null");
    } else {
      sb.append(this.check_type);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("check_operand:");
    if (this.check_operand == null) {
      sb.append("null");
    } else {
      sb.append(this.check_operand);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("set_diff_sort_key:");
    sb.append(this.set_diff_sort_key);
    first = false;
    if (!first) sb.append(", ");
    sb.append("set_sort_key:");
    if (this.set_sort_key == null) {
      sb.append("null");
    } else {
      sb.append(this.set_sort_key);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("set_value:");
    if (this.set_value == null) {
      sb.append("null");
    } else {
      sb.append(this.set_value);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("set_expire_ts_seconds:");
    sb.append(this.set_expire_ts_seconds);
    first = false;
    if (!first) sb.append(", ");
    sb.append("return_check_value:");
    sb.append(this.return_check_value);
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // check for sub-struct validity
    if (hash_key != null) {
      hash_key.validate();
    }
    if (check_sort_key != null) {
      check_sort_key.validate();
    }
    if (check_operand != null) {
      check_operand.validate();
    }
    if (set_sort_key != null) {
      set_sort_key.validate();
    }
    if (set_value != null) {
      set_value.validate();
    }
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(
          new org.apache.thrift.protocol.TCompactProtocol(
              new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in)
      throws java.io.IOException, java.lang.ClassNotFoundException {
    try {
      // it doesn't seem like you should have to do this, but java serialization is wacky, and
      // doesn't call the default constructor.
      __isset_bitfield = 0;
      read(
          new org.apache.thrift.protocol.TCompactProtocol(
              new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class check_and_set_requestStandardSchemeFactory
      implements org.apache.thrift.scheme.SchemeFactory {
    public check_and_set_requestStandardScheme getScheme() {
      return new check_and_set_requestStandardScheme();
    }
  }

  private static class check_and_set_requestStandardScheme
      extends org.apache.thrift.scheme.StandardScheme<check_and_set_request> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, check_and_set_request struct)
        throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true) {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
          break;
        }
        switch (schemeField.id) {
          case 1: // HASH_KEY
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.hash_key = new blob();
              struct.hash_key.read(iprot);
              struct.setHash_keyIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // CHECK_SORT_KEY
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.check_sort_key = new blob();
              struct.check_sort_key.read(iprot);
              struct.setCheck_sort_keyIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // CHECK_TYPE
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.check_type = cas_check_type.findByValue(iprot.readI32());
              struct.setCheck_typeIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // CHECK_OPERAND
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.check_operand = new blob();
              struct.check_operand.read(iprot);
              struct.setCheck_operandIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // SET_DIFF_SORT_KEY
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.set_diff_sort_key = iprot.readBool();
              struct.setSet_diff_sort_keyIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // SET_SORT_KEY
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.set_sort_key = new blob();
              struct.set_sort_key.read(iprot);
              struct.setSet_sort_keyIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // SET_VALUE
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.set_value = new blob();
              struct.set_value.read(iprot);
              struct.setSet_valueIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 8: // SET_EXPIRE_TS_SECONDS
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.set_expire_ts_seconds = iprot.readI32();
              struct.setSet_expire_ts_secondsIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 9: // RETURN_CHECK_VALUE
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.return_check_value = iprot.readBool();
              struct.setReturn_check_valueIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();

      // check for required fields of primitive type, which can't be checked in the validate method
      struct.validate();
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot, check_and_set_request struct)
        throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.hash_key != null) {
        oprot.writeFieldBegin(HASH_KEY_FIELD_DESC);
        struct.hash_key.write(oprot);
        oprot.writeFieldEnd();
      }
      if (struct.check_sort_key != null) {
        oprot.writeFieldBegin(CHECK_SORT_KEY_FIELD_DESC);
        struct.check_sort_key.write(oprot);
        oprot.writeFieldEnd();
      }
      if (struct.check_type != null) {
        oprot.writeFieldBegin(CHECK_TYPE_FIELD_DESC);
        oprot.writeI32(struct.check_type.getValue());
        oprot.writeFieldEnd();
      }
      if (struct.check_operand != null) {
        oprot.writeFieldBegin(CHECK_OPERAND_FIELD_DESC);
        struct.check_operand.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(SET_DIFF_SORT_KEY_FIELD_DESC);
      oprot.writeBool(struct.set_diff_sort_key);
      oprot.writeFieldEnd();
      if (struct.set_sort_key != null) {
        oprot.writeFieldBegin(SET_SORT_KEY_FIELD_DESC);
        struct.set_sort_key.write(oprot);
        oprot.writeFieldEnd();
      }
      if (struct.set_value != null) {
        oprot.writeFieldBegin(SET_VALUE_FIELD_DESC);
        struct.set_value.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(SET_EXPIRE_TS_SECONDS_FIELD_DESC);
      oprot.writeI32(struct.set_expire_ts_seconds);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(RETURN_CHECK_VALUE_FIELD_DESC);
      oprot.writeBool(struct.return_check_value);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
  }

  private static class check_and_set_requestTupleSchemeFactory
      implements org.apache.thrift.scheme.SchemeFactory {
    public check_and_set_requestTupleScheme getScheme() {
      return new check_and_set_requestTupleScheme();
    }
  }

  private static class check_and_set_requestTupleScheme
      extends org.apache.thrift.scheme.TupleScheme<check_and_set_request> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, check_and_set_request struct)
        throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot =
          (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet optionals = new java.util.BitSet();
      if (struct.isSetHash_key()) {
        optionals.set(0);
      }
      if (struct.isSetCheck_sort_key()) {
        optionals.set(1);
      }
      if (struct.isSetCheck_type()) {
        optionals.set(2);
      }
      if (struct.isSetCheck_operand()) {
        optionals.set(3);
      }
      if (struct.isSetSet_diff_sort_key()) {
        optionals.set(4);
      }
      if (struct.isSetSet_sort_key()) {
        optionals.set(5);
      }
      if (struct.isSetSet_value()) {
        optionals.set(6);
      }
      if (struct.isSetSet_expire_ts_seconds()) {
        optionals.set(7);
      }
      if (struct.isSetReturn_check_value()) {
        optionals.set(8);
      }
      oprot.writeBitSet(optionals, 9);
      if (struct.isSetHash_key()) {
        struct.hash_key.write(oprot);
      }
      if (struct.isSetCheck_sort_key()) {
        struct.check_sort_key.write(oprot);
      }
      if (struct.isSetCheck_type()) {
        oprot.writeI32(struct.check_type.getValue());
      }
      if (struct.isSetCheck_operand()) {
        struct.check_operand.write(oprot);
      }
      if (struct.isSetSet_diff_sort_key()) {
        oprot.writeBool(struct.set_diff_sort_key);
      }
      if (struct.isSetSet_sort_key()) {
        struct.set_sort_key.write(oprot);
      }
      if (struct.isSetSet_value()) {
        struct.set_value.write(oprot);
      }
      if (struct.isSetSet_expire_ts_seconds()) {
        oprot.writeI32(struct.set_expire_ts_seconds);
      }
      if (struct.isSetReturn_check_value()) {
        oprot.writeBool(struct.return_check_value);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, check_and_set_request struct)
        throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot =
          (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet incoming = iprot.readBitSet(9);
      if (incoming.get(0)) {
        struct.hash_key = new blob();
        struct.hash_key.read(iprot);
        struct.setHash_keyIsSet(true);
      }
      if (incoming.get(1)) {
        struct.check_sort_key = new blob();
        struct.check_sort_key.read(iprot);
        struct.setCheck_sort_keyIsSet(true);
      }
      if (incoming.get(2)) {
        struct.check_type = cas_check_type.findByValue(iprot.readI32());
        struct.setCheck_typeIsSet(true);
      }
      if (incoming.get(3)) {
        struct.check_operand = new blob();
        struct.check_operand.read(iprot);
        struct.setCheck_operandIsSet(true);
      }
      if (incoming.get(4)) {
        struct.set_diff_sort_key = iprot.readBool();
        struct.setSet_diff_sort_keyIsSet(true);
      }
      if (incoming.get(5)) {
        struct.set_sort_key = new blob();
        struct.set_sort_key.read(iprot);
        struct.setSet_sort_keyIsSet(true);
      }
      if (incoming.get(6)) {
        struct.set_value = new blob();
        struct.set_value.read(iprot);
        struct.setSet_valueIsSet(true);
      }
      if (incoming.get(7)) {
        struct.set_expire_ts_seconds = iprot.readI32();
        struct.setSet_expire_ts_secondsIsSet(true);
      }
      if (incoming.get(8)) {
        struct.return_check_value = iprot.readBool();
        struct.setReturn_check_valueIsSet(true);
      }
    }
  }

  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(
      org.apache.thrift.protocol.TProtocol proto) {
    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme())
            ? STANDARD_SCHEME_FACTORY
            : TUPLE_SCHEME_FACTORY)
        .getScheme();
  }
}
